//
//  TableIntervalCell.m
//  iiecg
//
//  Created by Shanlin on 2017/3/2.
//  Copyright © 2017年 Boundary Technology. All rights reserved.
//

#import "TableIntervalCell.h"

@interface TableIntervalCell ()

@property(nonatomic,strong)TableIntervalBean * bean;

@end

@implementation TableIntervalCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}


-(void)setBean:(TableIntervalBean *)bean
{
    __weak typeof(self)weakSelf = self;
    _bean = bean;
    if (!bean) {
        return;
    }
    [IKPublicUtil runOnMainThread:^{
        weakSelf.contentView.backgroundColor = bean.intervalColor;
    }];
}

+(instancetype)createWith:(UITableView*)tableView bean:(TableIntervalBean*)bean{
    static NSString *ID = @"TableIntervalCell";
    TableIntervalCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:ID owner:nil options:nil] lastObject];
    } else {
        while ([cell.contentView.subviews lastObject] != nil) {
            [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
        }
    }
    cell.bean = bean;
    return cell;

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
